package com.shiguiwu.springmybatis.spring.event.demo;

import org.springframework.context.event.ApplicationEventMulticaster;
import org.springframework.context.event.SimpleApplicationEventMulticaster;

import java.util.UUID;

/**
 * @description: 案例
 * 实现功能：电商中订单创建成功之后，给下单人发送一封邮件，发送邮件的功能放在监听器中实现。
 * @author: stone
 * @date: Created by 2021/4/8 18:55
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.spring.event.demo
 */
public class SpringEventTests {

    public static void main(String[] args) {

        ApplicationEventMulticaster multicaster = new SimpleApplicationEventMulticaster();
        multicaster.addApplicationListener(new SendEmailOnOrderCreateListener());

        multicaster.multicastEvent(new OrderCreateEvent(multicaster, UUID.randomUUID().toString()));

    }
}
